# -*- coding：utf-8 -*-
"""
@Time:2024-10-0622:38
@Auth:泛彼泊舟
@File:model_util.py
@IDE:PyCharm
@模块功能：校验yaml
"""
import dataclasses


@dataclasses.dataclass
class CaseInfo:
    # 必填
    feature: str
    story: str
    title: str
    request: dict
    validate: dict
    # 选填
    extract: dict = None

# 校验测试用例内容
def verify_yaml(caseinfo: dict):
    try:
        new_caseinfo = CaseInfo(**caseinfo)
        return new_caseinfo
    except Exception:
        raise Exception("测试用例yaml文件不符合规范")

# if __name__ == '__main__':
#     a = {'feature': '论坛模块',
#          'story': 'phpwind首页接口',
#          'title': '验证phpwind接口正常返回',
#          'request': {'method': 'get',
#                      'url': 'http://47.107.116.139/phpwind/'},
#          'validate': None
#          }
#     new_caseinfo = verify_yaml(a)
#     print(new_caseinfo.feature)
#     print(new_caseinfo.story)
#     print(new_caseinfo.request)